// pages/recruit/single/single.js
const tcity = require("../../../utils/citys.js");
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    //submit 封装 Start
    area_name: '',
    plat_id: '',
    anchor_type: '',
    pay_low: '',
    pay_high: '',
    salary_type: '',
    keep_pay: '',
    job_method: '4',
    page: 1,
    role: '',
    offset: 0,
    recommend_new: 1,
    publish_type: '',
    anchor_tab: '',
    move_card: false,
    //submit 封装 End

    //省市区 Start
    provinces: [],
    province: "",
    citys: [],
    city: "",
    countys: [],
    county: '',
    value: [0, 0, 0],
    values: [0, 0, 0],
    //code
    provincesCode: [],
    citysCode: [],
    countysCode: [],
    provinceCode: '',
    cityCode: '',
    countyCode: '',
    //省市区 End

    //选项卡 Flag
    area_show: true,
    plat_show: true,
    type_show: true,
    salary_show: true,
    cycle_show: true,
    recommend_show: true,

    leixing_num: '',
    yaoqiu_num: '',

    //开关
    oneMore: '1',
    twoMore: '1',
    kong_show: true,
    flag_special: false,


    //平台、类型循环
    platfrom: [],
    recuitType: [],
    timeList: [{
        id: 1,
        name: '月结',
        isSelected: false,
      },
      {
        id: 2,
        name: '周结',
        isSelected: false,
      },
      {
        id: 3,
        name: '日结',
        isSelected: false,
      },
    ],
    jobList: [{
        id: 1,
        name: '线上',
        isSelected: false,
      },
      {
        id: 2,
        name: '线下',
        isSelected: false,
      },
    ],
    expectList: [{
        pay_low: "",
        pay_high: "",
        name: '不限',
        isSelected: true,
      },
      {
        pay_low: "3000",
        pay_high: "",
        name: '3K以下',
        isSelected: false,
      },
      {
        pay_low: "3000",
        pay_high: "5000",
        name: '3K-5K',
        isSelected: false,
      },
      {
        pay_low: "",
        pay_high: "5000",
        name: '5K以上',
        isSelected: false,
      },
    ],
    baseList: [{
        keep_pay: "",
        name: "不限",
        isSelected: true,
      },
      {
        keep_pay: "1",
        name: "有底薪",
        isSelected: true,
      },
      {
        keep_pay: "2",
        name: "无底薪",
        isSelected: true,
      },
    ],
    // //submit 封装 Start
    // area_name: '',
    // plat_id: '',
    // anchor_type: '',
    // pay_low: '',
    // pay_high: '',
    // salary_type: '',
    // keep_pay: '',
    // job_method: '4',
    // page: 1,
    // role: '',
    // offset: 0,
    // move_card: false,
    // //submit 封装 End
    // anchor_page: 1,
    // resumes: [], //所有
    // resumes_odd: [], //奇数
    // resumes_even: [], //偶数
    // // 卡片切换列表
    // list_page: 1,
    // card_page: 1,
    // not_consider: 0,
    // now_num: 0,
    // orign_num: 0,
    // is_last: false,


    // //省市区 Start
    // provinces: [],
    // province: "",
    // citys: [],
    // city: "",
    // countys: [],
    // county: '',
    // value: [0, 0, 0],
    // values: [0, 0, 0],
    // //code
    // provincesCode: [],
    // citysCode: [],
    // countysCode: [],
    // provinceCode: '',
    // cityCode: '',
    // countyCode: '',
    // //省市区 End

    // //选项卡 Flag
    // area_show: true,
    // plat_show: true,
    // type_show: true,
    // salary_show: true,
    // cycle_show: true,


    // leixing_num: '',
    // yaoqiu_num: '',

    //开关
    flag_on: false,
    idx: '',
    plat_idx: '',
    plat_checked: false,
    expectindex: '0',
    baseindex: '0',
    platfromIndex: "-1",
    recuittypeindex: "-1",
    timelistindex: "-1",
    jobindex: "-1",
    mask_show: false,
    kong_show: true,
    oneMore: '1',
    twoMore: '1',



    base_low: '',
    base_high: '',
    expect_low: '',
    expect_high: '',

    special: 1,
    flag_moreTag: false,

    // //平台、类型循环
    // platfrom: [],
    // recuitType: [],
    // timeList: [{
    //     id: 1,
    //     name: '月结',
    //     isSelected: false,
    //   },
    //   {
    //     id: 2,
    //     name: '周结',
    //     isSelected: false,
    //   },
    //   {
    //     id: 3,
    //     name: '日结',
    //     isSelected: false,
    //   },
    // ],
    // jobList: [{
    //     id: 1,
    //     name: '线上',
    //     isSelected: false,
    //   },
    //   {
    //     id: 2,
    //     name: '线下',
    //     isSelected: false,
    //   },
    // ],
    // expectList: [{
    //     pay_low: "",
    //     pay_high: "",
    //     name: '不限',
    //     isSelected: true,
    //   },
    //   {
    //     pay_low: "3000",
    //     pay_high: "",
    //     name: '3K以下',
    //     isSelected: false,
    //   },
    //   {
    //     pay_low: "3000",
    //     pay_high: "5000",
    //     name: '3K-5K',
    //     isSelected: false,
    //   },
    //   {
    //     pay_low: "",
    //     pay_high: "5000",
    //     name: '5K以上',
    //     isSelected: false,
    //   },
    // ],
    // baseList: [{
    //     keep_pay: "",
    //     name: "不限",
    //     isSelected: true,
    //   },
    //   {
    //     keep_pay: "1",
    //     name: "有底薪",
    //     isSelected: true,
    //   },
    //   {
    //     keep_pay: "2",
    //     name: "无底薪",
    //     isSelected: true,
    //   },
    // ],

    // //招聘信息
    // recruit_info: [],
    // list: [],
    // recruit_phone: '',

    // //banner
    // banner: [],
    // navInfo: [],


    // // 卡片 Start
    // touch_startX: '',
    // touch_EndX: '',
    // nolike: 1, //                     记得修改
    // clickLike: '',
    // recruit_id: '',
    // show_modalWrap: true,
    // modalIndex: '',

    // //模态显示
    // //more_show
    // more_show: true,
    // flag_phone: true,
    // shape_show: true,
    // flag_out: true,

    // flag: true,
    // flag_time: true,
    // flag_share: true,
    // text_time: '',
    // reg_true: false,
    // flag_contact: true,
    // flag_info: true,
    // flag_weixin: false,
    // flag_qq: false,
    // flag_email: false,

    // flag_float: true,
    // flag_falls: false,
    // mark_falls: true,


    // // 找主播弹框开始

    // flag_find_anchor_nojob: true,
    // flag_find_anchor_call: true,
    // flag_find_anchor_stay: true,
    // flag_find_anchor_call_no: true,
    // flag_find_anchor_stay_no: true,
    // flag_find_anchor_jobing: true,
    // flag_find_anchor_call_bodou: true,
    // flag_find_anchor_call_bodou_no: true,


    // //简历信息获取
    // phone_value: '',
    // is_resume: '',
    // nickname: '',
    // age: '',
    // sex: '',

    // flag_list: false,



    // // 卡片 End
    // // 动画 Start
    // animation: null,
    // // 动画 End


    // //招聘 找主播页面数据
    // is_leave: '',
    // resume_id: '',
    // telephone: '',

    // is_issue: '',
    // residue_num: '',
    // re_number: '',
    // focus: false,
    // reg_telephone: '',
    // after_telephone: '',

    // mini_index: 0,
    // flag_index: '',
  },
  //拓展开
  click_twoMore: function() {
    if (this.data.twoMore == '1') {
      this.setData({
        twoMore: '2',
      })
    } else {
      this.setData({
        twoMore: '1',
      })
    }
  },
  //拓展开
  click_oneMore: function() {
    if (this.data.oneMore == '1') {
      this.setData({
        oneMore: '2',
      })
    } else {
      this.setData({
        oneMore: '1',
      })
    }
  },
  //禁止滚动
  preventTouchMove() {

  },
  //点击全国
  click_country: function() {
    this.setData({
      county: "全国",
      area_name: '',
    })
    this.open()
  },
  // input_base_high
  input_base_high: function(e) {
    this.setData({
      baseindex: null,
      base_high: e.detail.value,
    })
  },
  // input_base_low
  input_base_low: function(e) {
    this.setData({
      baseindex: null,
      base_low: e.detail.value,
    })
  },
  // focus_expect_high
  input_expect_high: function(e) {
    console.log(e.detail.value)
    this.setData({
      expectindex: null,
      pay_high: e.detail.value,
      expect_high: e.detail.value,
    })
  },
  // focus_expect_low
  input_expect_low: function(e) {
    this.setData({
      expectindex: null,
      pay_low: e.detail.value,
      expect_low: e.detail.value,
    })
  },
  //期望底薪
  click_base: function(e) {
    console.log(e)

    this.setData({
      baseindex: e.currentTarget.dataset.baseindex,
      keep_pay: e.currentTarget.dataset.keep_pay,
    })
    // console.log(keep_pay)
  },
  //期望薪资
  click_expect: function(e) {
    console.log(e.currentTarget.dataset)
    this.setData({
      expectindex: e.currentTarget.dataset.expectindex,
      pay_low: e.currentTarget.dataset.pay_low,
      pay_high: e.currentTarget.dataset.pay_high,
      expect_low: null,
      expect_high: null,
    })
  },
  //工作方式
  click_jobId(e) {
    // console.log(e.currentTarget.dataset);
    let that = this;

    let jobindex = e.currentTarget.dataset.joblist_id - 1;
    that.setData({
      jobindex: jobindex,
    })
    if (this.data.jobindex == "0") {
      console.log("线上")
      that.setData({
        job_method: "1",
      })
    } else if (this.data.jobindex == "1") {
      console.log("线下")
      that.setData({
        job_method: "2",
      })
    } else {
      console.log("全部")
      that.setData({
        jobindex: "-1",
        job_method: "4",
      })
    }
  },
  //选择结算周期
  click_time: function(e) {
    console.log(e);
    if (e.currentTarget.dataset.timelistindex >= 0) {
      this.setData({
        timelistindex: null,
      })
      //点击除了全部
      let timeList = this.data.timeList;
      // console.log(this.data.timeList)
      let index = e.currentTarget.dataset.timelistindex;
      let item = timeList[index];
      item.isSelected = !item.isSelected;
      // console.log(item)
      //加入选择的主播类型
      let timelist_id = e.currentTarget.dataset.timelist_id;
      let salary_type = this.data.salary_type;
      if (this.data.salary_type == "") {
        salary_type = this.data.salary_type + timelist_id
      } else {
        if (this.data.salary_type.indexOf(timelist_id) == "-1") {
          salary_type = this.data.salary_type + ',' + timelist_id
        } else {
          if (salary_type.length > 1) {
            salary_type = salary_type.replace(timelist_id + ',', "")
            salary_type = salary_type.replace(',' + timelist_id, "")
          } else {
            salary_type = salary_type.replace(timelist_id, "")
          }
        }
      }
      this.setData({
        timeList: this.data.timeList,
        salary_type: salary_type,
      })
      // console.log(this.data.salary_type)
    } else {
      //点击全部
      let timeList = this.data.timeList;
      for (var i = 0; i < timeList.length; i++) {
        timeList[i]["isSelected"] = false;
      }
      this.setData({
        salary_type: '',
        timeList: timeList,
        timelistindex: "-1",
      })
    }
  },
  //选择直播类型
  click_platType: function(e) {
    console.log(e)
    if (e.currentTarget.dataset.recuittypeindex >= 0) {
      this.setData({
        recuittypeindex: null,
      })
      //点击除了全部
      let recuitType = this.data.recuitType;
      // console.log(this.data.recuitType)    
      let index = e.currentTarget.dataset.recuittypeindex;
      let item = recuitType[index];
      item.isSelected = !item.isSelected;
      //加入选择的主播类型
      let anchortype_id = e.currentTarget.dataset.anchortype_id;
      let anchor_type = this.data.anchor_type;
      if (this.data.anchor_type == "") {
        anchor_type = this.data.anchor_type + anchortype_id
      } else {
        if (this.data.anchor_type.indexOf(anchortype_id) == "-1") {
          anchor_type = this.data.anchor_type + ',' + anchortype_id
        } else {
          if (anchor_type.length > 1) {
            anchor_type = anchor_type.replace(anchortype_id + ',', "")
            anchor_type = anchor_type.replace(',' + anchortype_id, "")
          } else {
            anchor_type = anchor_type.replace(anchortype_id, "")
          }
        }
      }
      this.setData({
        recuitType: this.data.recuitType,
        anchor_type: anchor_type,
      })
      console.log(this.data.anchor_type)
      // console.log(this.data.recuitType)
    } else {
      //点击全部
      let recuitType = this.data.recuitType;
      for (var i = 0; i < recuitType.length; i++) {
        recuitType[i]["isSelected"] = false;
      }
      this.setData({
        anchor_type: '',
        recuitType: recuitType,
        recuittypeindex: "-1",
      })
    }
  },
  //选择平台
  click_platId: function(e) {
    console.log(e)
    if (e.currentTarget.dataset.platfromindex >= 0) {
      this.setData({
        platfromIndex: null,
      })
      //点击除了全部
      let platfrom = this.data.platfrom;
      // console.log(this.data.platfrom)
      let index = e.currentTarget.dataset.platfromindex;
      let item = platfrom[index];
      item.isSelected = !item.isSelected;
      //加入选择的平台id
      let platfrom_id = e.currentTarget.dataset.platfrom_id;
      let plat_id = this.data.plat_id;
      if (this.data.plat_id == "") {
        plat_id = this.data.plat_id + platfrom_id;
      } else {
        if (this.data.plat_id.indexOf(platfrom_id) == "-1") {
          plat_id = this.data.plat_id + ',' + platfrom_id
        } else {
          if (plat_id.length > 1) {
            plat_id = plat_id.replace(platfrom_id + ',', "")
            plat_id = plat_id.replace(',' + platfrom_id, "")
          } else {
            plat_id = plat_id.replace(platfrom_id, "")
          }
        }
      }
      this.setData({
        platfrom: this.data.platfrom,
        plat_id: plat_id,
      })
      // console.log(this.data.plat_id)
      // console.log(this.data.platfrom)
    } else {
      //点击全部
      let platfrom = this.data.platfrom;
      for (var i = 0; i < platfrom.length; i++) {
        platfrom[i]["isSelected"] = false;
      }
      this.setData({
        plat_id: '',
        platfrom: platfrom,
        platfromIndex: "-1",
      })
    }
  },
  //load 下拉加载
  load: function(e) {
    // console.log(e)
    var page = this.data.page;
    this.setData({
      page: page + 1,
    })
    console.log(this.data.page)
    this.submit(this.data.area_name, this.data.plat_id, this.data.anchor_type, this.data.pay_low, this.data.pay_high, this.data.salary_type, this.data.keep_pay, this.data.nolike, this.data.clickLike, this.data.job_method, this.data.page, this.data.offset, this.data.publish_type, this.data.anchor_tab, this.data.recommend_new);
  },
  //跳转详情页
  go_detail: function(e) {
    console.log(e)
    if (wx.getStorageSync('token') == '') {
      wx.showModal({
        content: '登录后才能看详情哦~',
        showCancel: true,
        cancelColor: '#333',
        confirmText: '登录',
        confirmColor: '#d0a76c',
        success: function(e) {
          if (e.confirm) {
            wx.redirectTo({
              url: '../../author/author',
            })
          }
        },
      })
    } else {
      if (!e.currentTarget.dataset.recruit_id) {
        var deatil_id = this.data.recruit_id;
      } else {
        var deatil_id = e.currentTarget.dataset.recruit_id;
      }
      wx.navigateTo({
        url: '../detail/detail?deatil_id=' + deatil_id,
      })
    }

  },
  //submit 封装发送请求
  submit: function (area_name, plat_id, anchor_type, pay_low, pay_high, salary_type, keep_pay, nolike, clickLike, job_method, page, offset, publish_type, anchor_tab, recommend_new) {
    // console.log("GOGOGO")
    wx.showLoading({
      title: '小主稍等~',
    })
    let that = this;
    wx.request({
      url: app.globalData.url + 'api/timing/recruit/list',
      method: 'POST',
      data: {
        token: app.globalData.token,
        area_name: area_name,
        plat_id: plat_id,
        anchor_type: anchor_type,
        pay_low: pay_low,
        pay_high: pay_high,
        salary_type: salary_type,
        keep_pay: keep_pay,
        nolike: nolike,
        clickLike: clickLike,
        job_method: job_method,
        page: page,
        offset: offset,
        publish_type: publish_type,
        anchor_tab: anchor_tab,
        recommend_new: recommend_new,
      },
      success: function(e) {
        console.log(e.data.data.list.data.length)
        // console.log(e.data.data.is_resume);

        that.setData({
          list: e.data.data.list,
          is_resume: e.data.data.is_resume,
        })
        // if (that.data.recruit_info) {
        //      that.setData({
        //           kong_show: false,
        //      })
        // } else {
        //      that.setData({
        //           kong_show: true,
        //      })
        // }

        if (that.data.page > 1) {
          //合并数组
          if (that.data.page >= e.data.data.list.last_page) {
            //到底
            console.log('到底啦')
            // wx.showToast({
            //   title: '到底啦~~',
            //   icon: 'none',
            // })
            that.setData({
              page: 1,
              is_last: true,
            })

          } else {
            //加载
            let recruit_info_new = e.data.data.list.data;
            let recruit_info_old = that.data.recruit_info;
            recruit_info_old.push(...recruit_info_new)
            that.setData({
              recruit_info: recruit_info_old,
            });
            // console.log(that.data.recruit_info)
          }
        } else {
          //普通情况
          that.setData({
            recruit_info: e.data.data.list.data,
          });
        }
        wx.hideLoading();
      }
    })
  },
  //确定
  open: function() {
    if (this.data.keep_pay >= "0") {
      var keep_num = 1;
    }
    if (this.data.pay_high >= "0") {
      var pay_num = 1;
    }
    var plat_num_str = this.data.plat_id;
    if (plat_num_str.split(",") == "") {
      var plat_num = 0;
    } else {
      var plat_num = plat_num_str.split(",").length;
    }

    // console.log(plat_num)

    var type_num_str = this.data.anchor_type;
    if (type_num_str.split(",") == "") {
      var type_num = 0;
    } else {
      var type_num = type_num_str.split(",").length;
    }


    var salary_num_str = this.data.salary_type;
    if (salary_num_str.split(",") == "") {
      var salary_num = 0;
    } else {
      var salary_num = salary_num_str.split(",").length;
    }


    this.setData({
      //mask
      mask_show: false,

      plat_show: true,
      type_show: true,
      salary_show: true,
      cycle_show: true,
      area_show: true,
      recommend_show:true,

      idx: '',
      flag_on: false,
      // 搜索初始化
      page: 1,
      recruit_info: [],

      //个数
      leixing_num: type_num + plat_num,
      yaoqiu_num: keep_num + pay_num + salary_num,
    })
    // if (this.data.base_low != '' && this.data.base_high != '') {
    //      if (this.data.base_low > this.data.base_high) {
    //           wx.showToast({
    //                icon: "none",
    //                title: '期望底薪区间输入错误',
    //           })
    //      } else {
    //           var keep_pay = this.data.base_low + '-' + this.data.base_high;
    //           this.setData({
    //                keep_pay: keep_pay,
    //           })
    //      }
    // } else {}
    if (this.data.pay_low > this.data.pay_high) {
      // wx.showToast({
      //   icon: "none",
      //   title: '期望薪资区间输入错误',
      // })
      //发送请求
      this.submit(this.data.area_name, this.data.plat_id, this.data.anchor_type, this.data.pay_low, this.data.pay_high, this.data.salary_type, this.data.keep_pay, this.data.nolike, this.data.clickLike, this.data.job_method, this.data.page, this.data.offset, this.data.publish_type, this.data.anchor_tab, this.data.recommend_new);
    } else {
      //发送请求
      this.submit(this.data.area_name, this.data.plat_id, this.data.anchor_type, this.data.pay_low, this.data.pay_high, this.data.salary_type, this.data.keep_pay, this.data.nolike, this.data.clickLike, this.data.job_method, this.data.page, this.data.offset, this.data.publish_type, this.data.anchor_tab, this.data.recommend_new);
    }
  },
  click_area: function(e) {
    // console.log(e.currentTarget.dataset.index);
    let area_show = this.data.area_show == true ? false : true;
    if (area_show == true) {
      var flag_on = false;
    } else {
      var flag_on = true;
    }
    if (this.data.county == "全国") {
      // console.log("选择东城")
      this.setData({
        county: '东城区',
        area_name: '东城区',
      })
    } else {}
    this.setData({
      //mask
      mask_show: true,
      kong_show: true,


      plat_show: true,
      type_show: true,
      salary_show: true,
      cycle_show: true,
      recommend_show:true,

      idx: e.currentTarget.dataset.index,

      area_show: false,
      // flag_on: flag_on,
      offset: 0,
    })
  },
  click_plat: function(e) {
    let plat_show = this.data.plat_show == true ? false : true;
    if (plat_show == true) {
      var flag_on = false;
    } else {
      var flag_on = true;
    }
    this.setData({
      //mask
      mask_show: true,
      kong_show: true,

      type_show: true,
      salary_show: true,
      cycle_show: true,
      area_show: true,
      recommend_show:true,

      idx: e.currentTarget.dataset.index,

      plat_show: false,
      // flag_on: flag_on,
      offset: 0,
    })
  },
  click_type: function(e) {
    let type_show = this.data.type_show == true ? false : true;
    if (type_show == true) {
      var flag_on = false;
    } else {
      var flag_on = true;
    }
    this.setData({
      //mask
      mask_show: true,
      kong_show: true,

      plat_show: true,
      salary_show: true,
      cycle_show: true,
      area_show: true,
      recommend_show:true,

      idx: e.currentTarget.dataset.index,

      type_show: false,
      // flag_on: flag_on,
      offset: 0,
    })
  },
  click_recom(e) {
    console.log(e)
    let recommend_new = e.currentTarget.dataset.recommend_new;
    this.setData({
      recommend_new: recommend_new,
    })
    this.open();
  },
  click_recommend(e) {
    let recommend_show = this.data.recommend_show == true ? false : true;
    this.setData({
      flag_stick: true,
    })
    if (recommend_show == true) {
      var flag_on = false;
    } else {
      var flag_on = true;
    }
    this.setData({
      //mask
      mask_show: true,
      kong_show: true,

      plat_show: true,
      salary_show: true,
      type_show: true,
      cycle_show: true,
      area_show: true,

      idx: e.currentTarget.dataset.index,

      recommend_show: false,
      // flag_on: flag_on,
      offset: 0,
    })
  },
  click_salary: function(e) {
    let salary_show = this.data.salary_show == true ? false : true;
    if (salary_show == true) {
      var flag_on = false;
    } else {
      var flag_on = true;
    }
    this.setData({
      //mask
      mask_show: true,
      kong_show: true,

      plat_show: true,
      type_show: true,
      cycle_show: true,
      area_show: true,
      recommend_show:true,

      idx: e.currentTarget.dataset.index,

      salary_show: false,
      // flag_on: flag_on,
      offset: 0,
    })
  },
  click_cycle: function(e) {
    let cycle_show = this.data.cycle_show == true ? false : true;
    if (cycle_show == true) {
      var flag_on = false;
    } else {
      var flag_on = true;
    }
    this.setData({
      //mask
      mask_show: true,
      kong_show: true,

      plat_show: true,
      type_show: true,
      salary_show: true,
      area_show: true,
      recommend_show:true,

      idx: e.currentTarget.dataset.index,

      cycle_show: false,
      // flag_on: flag_on,
      offset: 0,
    })
  },
  //省市区 Start
  bindChange: function(e) {
    //console.log(e);
    var val = e.detail.value
    var t = this.data.values;
    var cityData = this.data.cityData;

    if (val[0] != t[0]) {
      // console.log('province no ');
      const citys = [];
      const countys = [];

      const citysCode = [];
      const countysCode = [];

      for (let i = 0; i < cityData[val[0]].sub.length; i++) {
        citys.push(cityData[val[0]].sub[i].name)
        citysCode.push(cityData[val[0]].sub[i].code)
      }
      for (let i = 0; i < cityData[val[0]].sub[0].sub.length; i++) {
        countys.push(cityData[val[0]].sub[0].sub[i].name)
        countysCode.push(cityData[val[0]].sub[0].sub[i].code)
      }
      // console.log(countysCode)

      this.setData({
        province: this.data.provinces[val[0]],
        provinceCode: this.data.provincesCode[val[0]],

        city: cityData[val[0]].sub[0].name,
        cityCode: cityData[val[0]].sub[0].code,
        citys: citys,
        citysCode: citysCode,

        county: cityData[val[0]].sub[0].sub[0].name,
        countyCode: cityData[val[0]].sub[0].sub[0].code,
        countys: countys,


        values: val,
        value: [val[0], 0, 0]
      })
      // console.log(this.data.province)
      this.setData({
        county: this.data.province,
        area_name: this.data.province,
      })
      return;
    }
    if (val[1] != t[1]) {
      // console.log('city no');
      const countys = [];
      const countysCode = [];

      for (let i = 0; i < cityData[val[0]].sub[val[1]].sub.length; i++) {
        countys.push(cityData[val[0]].sub[val[1]].sub[i].name);
        countysCode.push(cityData[val[0]].sub[val[1]].sub[i].code);
      }

      this.setData({
        city: this.data.citys[val[1]],
        cityCode: this.data.citysCode[val[1]],

        county: cityData[val[0]].sub[val[1]].sub[0].name,
        countyCode: cityData[val[0]].sub[val[1]].sub[0].code,
        countys: countys,
        countysCode: countysCode,

        values: val,
        value: [val[0], val[1], 0]
      })
      // console.log(this.data.city)
      this.setData({
        county: this.data.city,
        area_name: this.data.city,
      })
      return;
    }
    if (val[2] != t[2]) {
      // console.log('county no');
      this.setData({
        county: this.data.countys[val[2]],
        countyCode: this.data.countysCode[val[2]],
        values: val
      })
      // console.log(this.data.county)
      this.setData({
        county: this.data.county,
        area_name: this.data.county,
      })
      return;
    }
  },
  //省市区 End

  // 直播类型获取
  get_type() {
    let that = this;
    wx.request({
      url: app.globalData.url + 'api/timing/platfrom/type',
      method: 'POST',
      data: {
        token: app.globalData.token,
      },
      success: function(e) {
        let platfrom = e.data.data.platfrom;
        let recuitType = e.data.data.recuitType;
        //增加 isSelected 属性
        for (var i = 0; i < platfrom.length; i++) {
          platfrom[i]["isSelected"] = false;
        }
        for (var i = 0; i < recuitType.length; i++) {
          recuitType[i]["isSelected"] = false;
        }
        that.setData({
          platfrom: platfrom,
          recuitType: recuitType,
        })
        // console.log(recuitType)
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let that = this;
    this.get_type();
    switch (options.flag) {
      case 'all':
        console.log("all")
        break;
      case 'sift':
        that.setData({
          sift: true,
          anchor_tab: options.anchor_type,
        })
        break;
      case 'official':
        that.setData({
          publish_type: '3',
        })
        break;
      case 'special':
        that.setData({
          salary_type: '2,3',
          flag_special: true,
        })
        break;
      default:
        console.log("none")
    }


    //省市区 Start
    // console.log("onLoad");
    tcity.init(that);
    var cityData = that.data.cityData;
    const provinces = [];
    const provincesCode = [];
    const citys = [];
    const citysCode = [];
    const countys = [];
    const countysCode = [];

    for (let i = 0; i < cityData.length; i++) {
      provinces.push(cityData[i].name);
      provincesCode.push(cityData[i].code);
    }
    // console.log('省份完成');
    for (let i = 0; i < cityData[0].sub.length; i++) {
      citys.push(cityData[0].sub[i].name);
      citysCode.push(cityData[0].sub[i].code);
    }
    // console.log('city完成');
    for (let i = 0; i < cityData[0].sub[0].sub.length; i++) {
      countys.push(cityData[0].sub[0].sub[i].name);
      countysCode.push(cityData[0].sub[0].sub[i].code);
    }
    that.setData({
      'provinces': provinces,
      'citys': citys,
      'countys': countys,
      'province': cityData[0].name,
      'city': cityData[0].sub[0].name,
      'county': '全国',
      // 'county': cityData[0].sub[0].sub[0].name,      
      //code
      'provincesCode': provincesCode,
      'citysCode': citysCode,
      'countysCode': countysCode,
      'provinceCode': cityData[0].code,
      'cityCode': cityData[0].sub[0].code,
      'countyCode': cityData[0].sub[0].sub[0].code
    })
    // console.log('初始化完成');
    //省市区 End
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    let that = this;
    this.submit(this.data.area_name, this.data.plat_id, this.data.anchor_type, this.data.pay_low, this.data.pay_high, this.data.salary_type, this.data.keep_pay, this.data.nolike, this.data.clickLike, this.data.job_method, this.data.page, this.data.offset, this.data.publish_type, this.data.anchor_tab, this.data.recommend_new);
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})